package algotithm.interview.携程test.test3;

import java.io.*;

/**
 * @author zhouyanxiang
 * @Date 2021-03-2021/3/18-19:55
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String s1 = reader.readLine();
        String s2 = reader.readLine();
        int num = calcSimilarity(s1,s2);
        writer.write(num + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

    static int calcSimilarity(String name1, String name2) {
        int n = name1.length();
        int m = name2.length();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += name1.charAt(i);
        }
        for (int j = 0; j < m; j++) {
            sum += name2.charAt(j);
        }
        int[][] dp = new int[n+1][m+1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (name1.charAt(i) == name2.charAt(j)) {
                    dp[i+1][j+1] = dp[i][j] + ((int) name1.charAt(i));
                } else {
                    dp[i+1][j+1] = Math.max(dp[i][j+1],dp[i+1][j]);
                }
            }
        }
        return sum - (dp[n][m] * 2);
    }
}
